package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.pojo.User;

@Mapper
public interface UserMapper {
    @Select("SELECT * FROM user WHERE id = #{id};")
    User getUserById(Integer id);
    @Select("SELECT * FROM user WHERE BINARY name = #{name};")
    User getUserByName(String name);


    @Insert("INSERT INTO user " + "(name, password, image_url, create_time, update_time) " +
            "VALUES (#{name}, #{password}, #{imageUrl}, NOW(), NOW());")
    void addUser(String name, String password, String imageUrl);

    @Delete("DELETE FROM user WHERE id = #{id};")
    void deleteUserById(Integer id);

    void updateUserById(User user);
}
